#install.packages("InteractionPoweR")
library(InteractionPoweR)

# racial resentment

test_power<-power_interaction_r2(
  alpha = 0.05,             # alpha, for the power analysis
  N = 437,    # N = seq(200,600,by = 10)              # sample size
  r.x1x2.y = -0.1141,           # interaction effect to test (correlation between x1*x2 and y)
  r.x1.y = -0.1274,              # correlation between x1 and y
  r.x2.y = -0.0288,              # correlation between x2 and y
  r.x1.x2 = -0.0224              # correlation between x1 and x2
)

test_power

# plot_power_curve(power_data = test_power, # output from power_interaction()
#                  power_target = .8,        # the power we want to achieve 
#                  x = "N"  # x variable
# )

# income 

test_power<-power_interaction_r2(
  alpha = 0.05,             # alpha, for the power analysis
  N = 590,                  # sample size
  r.x1x2.y = -0.0095,           # interaction effect to test (correlation between x1*x2 and y)
  r.x1.y = -0.1552,              # correlation between x1 and y
  r.x2.y = 0.1261,              # correlation between x2 and y
  r.x1.x2 = -0.0056              # correlation between x1 and x2
)

test_power


# sales tax revenue share

test_power<-power_interaction_r2(
  alpha = 0.05,             # alpha, for the power analysis
  N = 589,                  # sample size
  r.x1x2.y = -0.1716,           # interaction effect to test (correlation between x1*x2 and y)
  r.x1.y = -0.1552,              # correlation between x1 and y
  r.x2.y = -0.0809,              # correlation between x2 and y
  r.x1.x2 = -0.0540              # correlation between x1 and x2
)

test_power

# sales tax rate

test_power<-power_interaction_r2(
  alpha = 0.05,             # alpha, for the power analysis
  N = 589,                  # sample size
  r.x1x2.y = -0.1417,           # interaction effect to test (correlation between x1*x2 and y)
  r.x1.y = -0.1552,              # correlation between x1 and y
  r.x2.y = 0.0789,              # correlation between x2 and y
  r.x1.x2 = 0.0518              # correlation between x1 and x2
)

test_power



